﻿using System.Linq;
using GdNet.WebFramework.Domain.Repositories.ContentManagement;
using GdNet.WebFramework.Modules.Common.ModuleBase;
using GdNet.WebFramework.Modules.ContentManagement.Dtos;

namespace GdNet.WebFramework.Modules.ContentManagement.Actions
{
    public class AdminListContentItemAction : AbstractModuleActionService
    {
        private readonly IContentItemRepository _contentItemRepository;

        public AdminListContentItemAction(IContentItemRepository contentItemRepository)
        {
            _contentItemRepository = contentItemRepository;
        }

        public override object Execute(ActionDetail actionDetail)
        {
            var listOfContents = _contentItemRepository.GetAll();
            return listOfContents.Select(x => new ContentItemDto(x)).ToList();
        }
    }
}
